package edu.yuhf.wx.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import edu.yuhf.domain.Order;
import edu.yuhf.domain.OrderDetail;
import edu.yuhf.domain.Product;
import edu.yuhf.service.iface.OrderService;
import edu.yuhf.service.iface.ProductService;
import lombok.extern.log4j.Log4j;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author yuhf
 */
@RestController
@RequestMapping("/wx/api/v1/order")
@Log4j2
public class WxOrderController {

    @Resource
    OrderService orderService;
    @Resource
    ProductService produceService;

    @RequestMapping(value="/",method = RequestMethod.PUT)
    public Map<String,Object> addOrder(@RequestBody Order order){
        //存入订单信息，同时根据id查询相关的菜品数据，并将这些数据一起写入订单详情表中
        orderService.addOrder(order);
        Map<String,Object> resultMap=new HashMap<>();
        resultMap.put("result","ok");
        resultMap.put("orderId",order.getId());
        return resultMap;
    }
}
